diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2026-02-24 17:05:20 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2026-02-24 17:05:20 +0700 |
| commit | 59f1eeb9cb59c8ad3ae2a02a0682d8f01e0bf3b3 (patch) | |
| tree | 4f4f0e919e959124f6209b7a9e079ed590c26ef5 /src/pages/google_merchant/products/[page].js | |
| parent | 87733bb59bdd6ee3c1b54d006f8465ec1763a0aa (diff) | |
<Miqdad> cr google merchant
Diffstat (limited to 'src/pages/google_merchant/products/[page].js')
| -rw-r--r-- | src/pages/google_merchant/products/[page].js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js index 2a53f7c0..d2371eb7 100644 --- a/src/pages/google_merchant/products/[page].js +++ b/src/pages/google_merchant/products/[page].js @@ -33,7 +33,7 @@ export async function getServerSideProps({ res, query }) { '/shop/product/variant/', product.name, product.id, - true + true, ); const productId = product.code != '' ? product.code : product.id; const regexHtmlTags = /(<([^>]+)>)/gi; @@ -62,7 +62,7 @@ export async function getServerSideProps({ res, query }) { } if (product.categories[0]?.id) { const getProductTemplate = await getProductTemplateId( - product?.productTemplate ?? null + product?.productTemplate ?? null, ); i = i + 1; const id = @@ -112,8 +112,10 @@ export async function getServerSideProps({ res, query }) { item['g:custom_label_1'] = { '#text': 'Stok Tersedia' }; } - if (categoryName) { - item['g:custom_label_2'] = { '#text': categoryName }; + if (product.categories?.[0]?.name) { + item['g:custom_label_2'] = { + '#text': product.categories[0].name, + }; } if (product.lowestPrice.discountPercentage > 0) { @@ -146,21 +148,21 @@ export async function getServerSideProps({ res, query }) { const getBrandById = async (id) => { const brand = await axios( - `${process.env.SOLR_HOST}/solr/brands/select?q=id:${id}` + `${process.env.SOLR_HOST}/solr/brands/select?q=id:${id}`, ); return brand.data.response.docs[0] ?? null; }; const getProductTemplateId = async (id) => { const category = await axios( - `${process.env.SOLR_HOST}/solr/product/select?q=id:${id}` + `${process.env.SOLR_HOST}/solr/product/select?q=id:${id}`, ); return category.data.response.docs[0] ?? null; }; const getCategoryById = async (id) => { const category = await axios( - `${process.env.SOLR_HOST}/solr/categories/select?q=id:${id}` + `${process.env.SOLR_HOST}/solr/categories/select?q=id:${id}`, ); return category.data.response.docs[0] ?? null; }; |
